package com.wxz.ldap.p2;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.DnAttribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import org.springframework.ldap.support.LdapNameBuilder;

import javax.naming.Name;

/**
 * @author xianzhang.wang
 * @Description
 * @date 2018/7/12
 */
//@Entry(objectClasses = {"organizationalPerson", "Person", "top"}, base = "dc=wxz,dc=com")
//@Entry(base = "dc=wxz,dc=com",objectClasses = {"Person"})

/**
 * objectClasses必须指定，base可选
 */
@Entry(objectClasses = "Person")
public class User {

    /**
     * 标注的是这个实体的DN
     */
    @Id
    @JsonIgnore
    private Name dn;

    /**
     * @ Dnattribute标注的属性都是属于自动构建DN时的一部分
     */
    @DnAttribute("cn")
    private String cn;

    @DnAttribute("ou")
    private String ou;

    /**
     * 表明这是objectClass的一个属性
     */
    @Attribute(name = "sn")
    private String sn;

    public User() {
    }

    public User(String cn, String sn, Name dn) {
        this.cn = cn;
        this.sn = sn;
        this.dn = dn;
    }

    public Name getDn() {
        return dn;
    }

    public void setDn(Name dn) {
        this.dn = dn;
    }

    public String getCn() {
        return cn;
    }

    public void setCn(String cn) {
        this.cn = cn;
    }

    public String getOu() {
        return ou;
    }

    public void setOu(String ou) {
        this.ou = ou;
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Override
    public String toString() {
        return "User{" +
                "dn=" + dn +
                ", cn='" + cn + '\'' +
                ", ou='" + ou + '\'' +
                ", sn='" + sn + '\'' +
                '}';
    }
}
